package com.snbc.Exception;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @Classname FileException
 * @Description TODO
 * @Date 2019/9/14 21:30
 * @Created by Acer
 */
public class FileException {

    public static void main(String[] args) {
        File file = new File("F:\\sougou\\SogouInput\\readsme.txt");
        try {
            new FileInputStream(file);
            System.out.println("成功打开");
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            Date d = sdf.parse("2019-05-13");
            // System.out.println(sdf.format(d));
            System.out.println(d);
        } catch (FileNotFoundException | ParseException e) {
            if (e instanceof FileNotFoundException)
                System.out.println("文件不存在");
            if (e instanceof ParseException)
                System.out.println("日期格式解析错误");
            e.printStackTrace();
        } finally {
            System.out.println("无论文件是否存在， 都会执行的代码");
        }
    }
}
